
import 'package:cunyutech_flutter_ui/src/theme/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:fluttertoast/fluttertoast.dart';

Future<bool> showRequestError(String message) {
  return showToast(msg: message ?? "请求失败", gravity: ToastGravity.CENTER, toastLength: Toast.LENGTH_LONG);
}

Future<bool> showRequestSuccess(String message) {
  return showToast(msg: message ?? "请求成功", gravity: ToastGravity.CENTER, toastLength: Toast.LENGTH_LONG);
}

Future<bool> showToast({
    @required String msg,
    Toast toastLength,
    int timeInSecForIos = 1,
    double fontSize = CYFontSize.Middle,
    ToastGravity gravity = ToastGravity.CENTER,
    Color backgroundColor = const Color(0x99000000),
    Color textColor = Colors.white
}) {
  if(msg == null || msg == "") {
    return Future.value(false);
  }
  return Fluttertoast.showToast(
    msg: msg,
    toastLength: toastLength,
    gravity: gravity,
    fontSize: fontSize,
    backgroundColor: backgroundColor,
    textColor: textColor,
  );
}